package com.genexususa.eo.bing.data.wsSubclasses;

import com.genexususa.eo.bing.CampaignManagementServiceClasses.AdExtensionIdToCampaignIdAssociation;
import com.genexususa.eo.bing.CampaignManagementServiceClasses.AdExtensionIdToEntityIdAssociation;
import com.genexususa.eo.bing.data.GxItemException;
import org.w3c.dom.Element;
import org.w3c.dom.Node;

//public class GxAdExtensionIdToCampaignIdAssociation extends AdExtensionIdToCampaignIdAssociation {
public class GxAdExtensionIdToCampaignIdAssociation extends AdExtensionIdToEntityIdAssociation {
    private long gxAdExtensionId;
    private long gxCampaignId;

    public GxAdExtensionIdToCampaignIdAssociation(Element element) throws IllegalArgumentException, GxItemException {
        if (element.getElementsByTagName("GxAdExtensionId").getLength() > 0 &&
            element.getElementsByTagName("GxAdExtensionId").item(0).getChildNodes().getLength() > 0 &&
            Long.valueOf(((Node)element.getElementsByTagName("GxAdExtensionId").item(0).getChildNodes().item(0)).getNodeValue()) != 0) {
            this.gxAdExtensionId = Long.valueOf(((Node)element.getElementsByTagName("GxAdExtensionId").item(0).getChildNodes().item(0)).getNodeValue());
        } else {
            throw new GxItemException("Missing external AdExtension id");
        }
        if (element.getElementsByTagName("BingAdExtensionId").getLength() > 0 &&
            element.getElementsByTagName("BingAdExtensionId").item(0).getChildNodes().getLength() > 0 &&
            Long.valueOf(((Node)element.getElementsByTagName("BingAdExtensionId").item(0).getChildNodes().item(0)).getNodeValue()) != 0) {
            this.setAdExtensionId(Long.valueOf(((Node) element.getElementsByTagName("BingAdExtensionId").item(0).getChildNodes().item(0)).getNodeValue()));
        }
        if (element.getElementsByTagName("GxCampaignId").getLength() > 0 &&
            element.getElementsByTagName("GxCampaignId").item(0).getChildNodes().getLength() > 0 &&
            Long.valueOf(((Node)element.getElementsByTagName("GxCampaignId").item(0).getChildNodes().item(0)).getNodeValue()) != 0) {
            this.gxCampaignId = Long.valueOf(((Node)element.getElementsByTagName("GxCampaignId").item(0).getChildNodes().item(0)).getNodeValue());
        } else {
            throw new GxItemException("Missing external Campaign id");
        }
        if (element.getElementsByTagName("BingCampaignId").getLength() > 0 &&
            element.getElementsByTagName("BingCampaignId").item(0).getChildNodes().getLength() > 0 &&
            Long.valueOf(((Node)element.getElementsByTagName("BingCampaignId").item(0).getChildNodes().item(0)).getNodeValue()) != 0) {
            //this.setCampaignId(Long.valueOf(((Node) element.getElementsByTagName("BingCampaignId").item(0).getChildNodes().item(0)).getNodeValue()));
            this.setEntityId(Long.valueOf(((Node) element.getElementsByTagName("BingCampaignId").item(0).getChildNodes().item(0)).getNodeValue()));
        }
    }

    public long getGxAdExtensionId() {
        return gxAdExtensionId;
    }

    public void setGxAdExtensionId(long gxAdExtensionId) {
        this.gxAdExtensionId = gxAdExtensionId;
    }

    public long getGxCampaignId() {
        return gxCampaignId;
    }

    public void setGxCampaignId(long gxCampaignId) {
        this.gxCampaignId = gxCampaignId;
    }
}
